import 'dart:io';

import 'package:flutter/material.dart';

void main() {
  runApp(new ExpansionPanelPlugin());
}

/*
 * 折叠面板 <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class ExpansionPanelPlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new ExpansionPanelPluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class ExpansionPanelPluginState extends State<StatefulWidget> {
  bool _isExpanded = true;

  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        new Container(width: 0, height: 0),
        new Container(width: 0, height: 0),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return Column(
            children: <Widget>[
              ExpansionPanelList(
                children: <ExpansionPanel>[
                  ExpansionPanel(
                    headerBuilder: (context, isExpanded) {
                      return ListTile(
                        title: Text('我是标题'),
                      );
                    },
                    body: Padding(
                      padding: EdgeInsets.fromLTRB(15, 0, 15, 15),
                      child: ListBody(
                        children: <Widget>[
                          Card(
                            margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                            child: Padding(
                              padding: EdgeInsets.all(8),
                              child: Text('我是内容'),
                            ),
                          ),
                          Card(
                            margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                            child: Padding(
                              padding: EdgeInsets.all(8),
                              child: Text('我是内容'),
                            ),
                          ),
                          Card(
                            margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                            child: Padding(
                              padding: EdgeInsets.all(8),
                              child: Text('我是内容'),
                            ),
                          ),
                          Card(
                            margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                            child: Padding(
                              padding: EdgeInsets.all(8),
                              child: Text('我是内容'),
                            ),
                          ),
                          Card(
                            margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                            child: Padding(
                              padding: EdgeInsets.all(8),
                              child: Text('我是内容'),
                            ),
                          ),
                        ],
                      ),
                    ),
                    isExpanded: _isExpanded,
                    canTapOnHeader: true,
                  ),
                ],
                expansionCallback: (panelIndex, isExpanded) {
                  setState(() {
                    _isExpanded = !isExpanded;
                  });
                },
                animationDuration: kThemeAnimationDuration,
              ),
            ],
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }
}
